﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Runtime.Serialization;

namespace Ada.Protocol
{
    [ServiceContract(Namespace="http://www.tomdewey.co.uk/ada/ServerManager")]
    public interface IServerManager
    {
        [OperationContract]
        bool AddServer(string hostName, int port, int connectionCount, bool requiresLogin, string username, string password, bool SSL, bool needsGroup);
        [OperationContract]
        bool AddDownload(string nzbFile);

        [OperationContract]
        DownloadInformation GetDownloadInformation(string downloadName);

        [OperationContract]
        List<DownloadInformation> GetDownloads();

        [OperationContract]
        ServerInformation GetServerInformation();
    }

    [DataContract]
    public class DownloadInformation
    {
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string Size { get; set; }

        [DataMember]
        public string Progress { get; set; }

        [DataMember]
        public string Owner { get; set; }

        public DownloadInformation(string _name, string _size, string _progress, string _owner)
        {
            this.Name = _name;
            this.Size = _size;
            this.Progress = _progress;
            this.Owner = _owner;
        }
    }

    [DataContract]
    public class ServerInformation
    {
        [DataMember]
        public string Hostname { get; set; }

        [DataMember]
        public string osVersion { get; set; }

        [DataMember]
        public long diskCapacity { get; set; }

        [DataMember]
        public long diskUsage { get; set; }

        public ServerInformation(string _host, string _osVer, long _capacity, long _usage)
        {
            Hostname = _host;
            osVersion = _osVer;
            diskCapacity = _capacity;
            diskUsage = _usage;
        }

        public override string ToString()
        {
            string returnString;
            returnString = "Hostname: " + Hostname + '\n';
            returnString += "OS Version: " + osVersion + '\n';
            returnString += "Download Disk Capacity: " + diskCapacity + '\n';
            return base.ToString();
        }
    }
}
